<script setup lang="ts">
import { ref } from 'vue'
import { Edit, Document, Setting, InfoFilled, Calendar, View, Star, ChatDotRound, Delete } from '@element-plus/icons-vue'


// 模拟文章数据
const articles = ref([
  {
    id: 1,
    title: 'Vue3 + TypeScript 最佳实践',
    content: '分享在Vue3项目中使用TypeScript的一些经验和技巧...',
    date: '2024-01-15',
    likes: 24,
    comments: 8,
    views: 156
  },
  {
    id: 2,
    title: 'Element Plus 自定义主题指南',
    content: '详细讲解如何定制Element Plus的主题色彩，打造个性化界面...',
    date: '2024-01-12',
    likes: 18,
    comments: 5,
    views: 89
  },
  {
    id: 3,
    title: '前端工程化配置实战',
    content: '从零配置一个现代化的前端项目，包含ESLint、Prettier等工具...',
    date: '2024-01-10',
    likes: 32,
    comments: 12,
    views: 203
  },
  {
    id: 4,
    title: '前端工程化配置实战',
    content: '从零配置一个现代化的前端项目，包含ESLint、Prettier等工具...',
    date: '2024-01-10',
    likes: 32,
    comments: 12,
    views: 203
  }
])
</script>

<template>
  <div class="user-profile">
    
    

    <!-- 主要内容区域 -->
    <div class="profile-main">
      <!-- 文章列表 -->
      <el-card class="right-panel" shadow="never">
        <template #header>
          <div class="panel-header">
            <el-icon><Document /></el-icon>
            <span>发布的文章</span>
          </div>
        </template>
        
        <div class="articles-list">
          <div 
            v-for="article in articles" 
            :key="article.id" 
            class="article-item"
          >
            <div class="article-main">
              <h3 class="article-title">{{ article.title }}</h3>
              <p class="article-content">{{ article.content }}</p>
              <div class="article-meta">
                <span class="meta-item">
                  <el-icon><Calendar /></el-icon>
                  {{ article.date }}
                </span>
                <span class="meta-item">
                  <el-icon><View /></el-icon>
                  {{ article.views }}
                </span>
                <span class="meta-item">
                  <el-icon><Star /></el-icon>
                  {{ article.likes }}
                </span>
                <span class="meta-item">
                  <el-icon><ChatDotRound /></el-icon>
                  {{ article.comments }}
                </span>
              </div>
            </div>
            <div class="article-actions">
              <el-button text class="action-btn">
                <el-icon><Edit /></el-icon>
                编辑
              </el-button>
              <el-button text class="action-btn">
                <el-icon><Delete /></el-icon>
                删除
              </el-button>
            </div>
          </div>
        </div>
      </el-card>
    </div>
  </div>
</template>

<style scoped>
.user-profile {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* 主要内容区域 */
.profile-main {
  display: block;
  width: 100%;
}

.right-panel {
  width: 100%;
  border: 1px solid #e4e7ed;
  border-radius: 12px;
  background: #ffffff;
  box-sizing: border-box;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #1e293b;
}

.panel-header .el-icon {
  color: #3b82f6;
}

/* 文章列表 */
.articles-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.article-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  transition: all 0.3s ease;
  background: #f8fafc;
  width: 100%;
  box-sizing: border-box;
}

.article-item:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
}

.article-main {
  flex: 1;
}

.article-title {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 8px 0;
  cursor: pointer;
  transition: color 0.3s ease;
}

.article-title:hover {
  color: #3b82f6;
}

.article-content {
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 12px;
  font-size: 14px;
}

/* 恢复原来的灰色元数据样式 */
.article-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #94a3b8;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-item .el-icon {
  color: #64748b; /* 恢复原来的图标颜色 */
}

/* 恢复按钮样式 */
.article-actions {
  display: flex;
  gap: 8px;
}

.article-actions .action-btn {
  color: #64748b;
  transition: color 0.3s ease;
}

.article-actions .action-btn:hover {
  color: #3b82f6;
  background: transparent;
}

/* 美化其他元素 */
.article-item {
  position: relative;
  overflow: hidden;
}

.article-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, #3b82f6, #60a5fa);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.article-item:hover::before {
  opacity: 1;
}

/* 添加一些动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.article-item {
  animation: fadeInUp 0.5s ease forwards;
}

.article-item:nth-child(1) { animation-delay: 0.1s; }
.article-item:nth-child(2) { animation-delay: 0.2s; }
.article-item:nth-child(3) { animation-delay: 0.3s; }
.article-item:nth-child(4) { animation-delay: 0.4s; }

/* 响应式设计 */
@media (max-width: 768px) {
  .user-profile {
    padding: 15px;
  }
  
  .article-item {
    padding: 16px;
    flex-direction: column;
    gap: 12px;
  }
  
  .article-meta {
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .article-actions {
    align-self: flex-end;
    width: 100%;
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  .user-profile {
    padding: 10px;
  }
  
  .article-item {
    padding: 12px;
  }
  
  .article-title {
    font-size: 16px;
  }
  
  .article-content {
    font-size: 13px;
  }
  
  .article-meta {
    gap: 8px;
  }
  
  .meta-item {
    font-size: 11px;
  }
}

/* 美化滚动条（可选） */
.articles-list::-webkit-scrollbar {
  width: 6px;
}

.articles-list::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.articles-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.articles-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
</style>